package org.raymond.iworks.study.orders.common;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.map.UnmodifiableMap;
import org.raymond.iworks.study.orders.entity.TInventories;
import org.raymond.iworks.study.orders.entity.TInventoriesSegments;
import org.raymond.iworks.study.orders.repository.TInventoryRepository;
import org.raymond.iworks.study.orders.repository.TInventorySegmentsRepository;
import org.raymond.iworks.study.orders.service.ISecKillService;
import org.raymond.iworks.study.orders.service.impl.SecKillServiceImpl;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

@Slf4j
public class ActivityReadyEvent implements ApplicationListener<ApplicationReadyEvent> {
    // 初始化秒杀活动
    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        log.info("初始化秒杀活动开始...");
        ConfigurableApplicationContext ctx = event.getApplicationContext();
        ISecKillService service = ctx.getBean(SecKillServiceImpl.class);
        service.initSecKillActivity();
        log.info("初始化秒杀活动结束...");
    }
}
